// ==UserScript==
// @name           Stop Monitoring SFEE Trackers I Don't Own
// @namespace      oasis.mitra.com
// @description    Make sure I am NOT monitoring issues I don't own
// @include        http://oasis.mitra.com*artf*
// ==/UserScript==

var assignedToElements = document.getElementsByName('assignedUser');
var assignedToValue;
var assignedTo;
var me;

var meElement = document.getElementById('UserLoggedIn');
var end = meElement.innerHTML.lastIndexOf('&nbsp;');
me = meElement.innerHTML.substring(16, end);

for( var i = 0; i < assignedToElements.length; i++ )
{
	assignedToValue = assignedToElements[i];
}

var options = document.getElementsByTagName('option');

for( var j = 0; j < options.length; j++ )
{
	if( options[j].value == assignedToValue.value )
	{
		assignedTo = options[j].innerHTML;
		break;
	}
}

var stopMonitoringButton = document.getElementById('button_monitor_object');
if( stopMonitoringButton.innerHTML == 'Stop Monitoring' && assignedTo != me )
{
    window.location.href = stopMonitoringButton.href;
}
